db = require './connect'
async = require 'async'
fs = require 'fs'


contact = JSON.parse fs.readFileSync 'zakercontact.txt'

# console.log contact
run = ()->
	async.forEachSeries contact.MemberList, (account, cb)->
		account.isheadimg = ''
		account.active = '1'
		account.category = ''
		account.article_count = ''
		account.approved_count = ''
		sql = "insert ignore into accounts set ?"
		a = {}
		for i, v of account
			a[i.toLowerCase()] = v
			if i.toLowerCase() is 'memberlist'
				a[i.toLowerCase()] = null
		db.runSql sql, a , cb
	,(err)->
		console.log err if err

async.forEachSeries contact.MemberList, (account,cb)->
	db.runSql "update accounts set active = 1 where uin = ?", [account.uin], cb
,(err)->
	console.log err


# historyUrl = 'http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MjM5NTAyMDEwMA==&uin=MTExODcz&key=d6acaea0a22c6078fa200638ff40ee68fbc76c31d668a2594ad1e9af68b62a7ae977d600211d2ab27003d46331b3408f&frommsgid=-1&count%20=%2010&f=json'

# run()

